from models import *
from django.contrib.auth.models import User,UserManager
from django.db import models
from django.db.models import *
from django.contrib import admin


class ProfileManager(models.Manager):
    def create(self, u):     
        g = Group.objects.filter(name = "DefaultGroup")[0]
        pro = self.model(user=u,group = g,type=2)
        pro.save(using=self._db)
        return pro
    
class UserProfile(models.Model):
    user = models.ForeignKey(User, unique = True)
    group = models.ForeignKey(Group)
    Type =(
        (0 ,"Administrator"),
        (1 ,"Teacher"),
        (2, "Student"),
        )
    
    type = models.IntegerField(choices = Type, default = 2)
    
    photo = ImageField(upload_to="photo",blank=True)
    selfIntro = CharField(max_length = 150 ,blank=True)
    
    objects = ProfileManager()
